<!-- 扩展 -->
{eyou:case value="img"}
    <!-- 单张图 start -->
    <div class="form-group group_z">
        <div class="input-group input-group-icon">
            <input type="text" class="  form-control" id="{$vo.fieldArr}_{$vo.name|default=''}" name="{$vo.fieldArr}[{$vo.name|default=''}]" value="" style="display: none;"><!--{$vo.info|default=''}-->
            <input class=" form-control {$vo.fieldArr}_{$vo.name|default=''}_input" placeholder="{$vo.title}" style="height: 43px;" onClick="GetUploadify(1,'','allimg','{$vo.fieldArr}_{$vo.name|default=''}_call_back','{:url('user/Uploadify/upload',['resource'=>'reg'])}')">
        </div>
    </div>
    <script type="text/javascript">
        function {$vo.fieldArr}_{$vo.name|default=''}_call_back(fileurl_tmp)
        {
            $("#{$vo.fieldArr}_{$vo.name|default=''}").val(fileurl_tmp);
            $(".{$vo.fieldArr}_{$vo.name|default=''}_input").val(fileurl_tmp);
        }
    </script>
    <!-- 单张图 end -->
{/eyou:case}

{eyou:case value="imgs"}
<!-- 多张图 start -->
<div class="form-group group_z images_upload_main">
    <div class="input-group">
        <button type="button" style="text-align: left;" class="form-control" onClick="GetUploadify(100,'','allimg','{$vo.fieldArr}_{$vo.name|default=''}_call_back', '', '{$vo.title}');">
            {$vo.title}<span style="float: right;font-size: 14px;">点击上传</span>
        </button>
    </div>
    <div style="margin: 5px 0;padding: 3px;border: 1px dashed #ebeced;display: none;" id="upload_imgs_{$vo.fieldArr}_{$vo.name|default=''}">
        <!--上传填充-->
    </div>
    
    <!-- 上传图片显示的样板 start -->
    <div class="{$vo.fieldArr}_{$vo.name|default=''}_upload_tpl" style="display: none;">
        <div class="fieldext_upload fieldext_upload_html">
            <div class="images_upload_item">
                <input type="hidden" name="{$vo.fieldArr}[{$vo.name|default=''}][]" value="">
                <a href="" target="_blank">
                    <img src="__STATIC__/admin/images/add-button.jpg" width="42" height="42">
                </a>
                <a class="delete" href="javascript:void(0)" title="删除"></a>
            </div>
        </div>
    </div>
    <!-- 上传图片显示的样板 end -->
</div>
<script type="text/javascript">
    var GetUploadify_url = "{:url('user/Uploadify/upload',['resource'=>'reg'])}";

    // 上传多图回调函数
    function {$vo.fieldArr}_{$vo.name|default=''}_call_back(paths){
        var  last_div = $(".{$vo.fieldArr}_{$vo.name|default=''}_upload_tpl").html();
        for (var i=0;i<paths.length ;i++ )
        {
            if ($("#upload_imgs_{$vo.fieldArr}_{$vo.name|default=''} .fieldext_upload_html").length == 0) {
                $("#upload_imgs_{$vo.fieldArr}_{$vo.name|default=''}").css('display','');
            }
            $("#upload_imgs_{$vo.fieldArr}_{$vo.name|default=''}").append(last_div);  // 插入一个 新图片


            $("#upload_imgs_{$vo.fieldArr}_{$vo.name|default=''} .fieldext_upload_html:last").find('a:eq(0)').attr('href',paths[i]).attr('onclick','').attr('target', "_blank");// 修改他的链接地址
            $("#upload_imgs_{$vo.fieldArr}_{$vo.name|default=''} .fieldext_upload_html:last").find('img').attr('src',paths[i]);// 修改他的图片路径
            $("#upload_imgs_{$vo.fieldArr}_{$vo.name|default=''} .fieldext_upload_html:last").find('a:eq(1)').attr('onclick',"{$vo.fieldArr}_{$vo.name|default=''}_ClearPicArr2(this,'"+paths[i]+"')").text('');
            $("#upload_imgs_{$vo.fieldArr}_{$vo.name|default=''} .fieldext_upload_html:last").find('input').val(paths[i]); // 设置隐藏域 要提交的值
        }
    }
    /*
 * 上传之后删除组图input
 * @access   public
 * @val      string  删除的图片input
 */
    function {$vo.fieldArr}_{$vo.name|default=''}_ClearPicArr2(obj,path)
    {
        $(obj).parent().parent().remove();
        if ($("#upload_imgs_{$vo.fieldArr}_{$vo.name|default=''} .fieldext_upload_html").length == 0) {
            $("#upload_imgs_{$vo.fieldArr}_{$vo.name|default=''}").css('display','none');
        }
    }
</script>
<!-- 多张图 end -->
{/eyou:case}


{case value="file"}
{eyou:static file="/public/plugins/layui/css/layui.css" /}
{eyou:static file="/public/plugins/layui/layui.js" /}
<!-- 单个文件 start -->
<div class="form-group group_z">
    <div class="input-group">
        <input type="text" id="{$vo.fieldArr}_{$vo.name|default=''}" name="{$vo.fieldArr}[{$vo.name|default=''}]" value="{$vo.dfvalue|default=''}" style="display: none;">
        <button type="button" style="text-align: left;" class="form-control" id="upload_{$vo.fieldArr}_{$vo.name|default=''}" ><i class="el-icon-paperclip"></i>{$vo.title}<span style="float: right;font-size: 14px;" id="btntxt_file_{$vo.fieldArr}_{$vo.name|default=''}">点击上传</span></button>
        <!-- <a id="download_file_{$vo.fieldArr}_{$vo.name|default=''}" style="margin-left: 10px;text-decoration: underline;{eyou:notempty name='$vo.dfvalue' /}display: 'block';{eyou:else /}display: none;{/eyou:notempty}" {eyou:notempty name='$vo.dfvalue' /} href="{$vo.dfvalue|default=''}"  download="{$vo.dfvalue|get_filename=###}" {/eyou:notempty}>
            <img src="__STATIC__/common/images/file.png" alt="" style="width: 16px;height:  16px;">下载附件
        </a> -->
    </div>
</div>

<script>
    $(function(){
        layui.use('upload', function(){
            var upload = layui.upload;

            //执行实例
            upload.render({
                elem: "#upload_{$vo.fieldArr}_{$vo.name|default=''}" //绑定元素
                ,url: "{:url('user/Uploadify/DownloadUploadFileAjax')}"
                ,exts: '{$vo.ext}'
                ,size: {$vo.filesize} //限制文件大小，单位 KB
                ,accept: 'file' //普通文件
                ,done: function(res){
                    //上传完毕回调
                    if (res.state=="SUCCESS"){
                        layer.msg('上传成功!')
                        $("#btntxt_file_{$vo.fieldArr}_{$vo.name|default=''}").text('已上传');
                        // $("#{$vo.fieldArr}_{$vo.name|default=''}").val(res.url);
                        // $("#download_file_{$vo.fieldArr}_{$vo.name|default=''}").css('display','');
                        // $("#download_file_{$vo.fieldArr}_{$vo.name|default=''}").attr('href',res.url);
                        // var arr = res.url.split("/");
                        // var download = arr[arr.length-1];
                        // $("#download_file_{$vo.fieldArr}_{$vo.name|default=''}").attr('download',download);
                        // $("#download_file_{$vo.fieldArr}_{$vo.name|default=''}").css('color','#000');
                        // $("#download_file_{$vo.fieldArr}_{$vo.name|default=''}").html('<img src="__STATIC__/common/images/file.png" alt="" style="width: 16px;height:  16px;">下载附件');
                    }else {
                        $("#btntxt_file_{$vo.fieldArr}_{$vo.name|default=''}").text('点击上传');
                        // $("#download_file_{$vo.fieldArr}_{$vo.name|default=''}").css('display','');
                        // $("#download_file_{$vo.fieldArr}_{$vo.name|default=''}").css('color','red');
                        // $("#download_file_{$vo.fieldArr}_{$vo.name|default=''}").text(res.state);
                    }
                }
                ,error: function(){
                    //请求异常回调
                }
            });
        });
    })
</script>
<!-- 单个文件 end -->
{/case}